<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="g" uri="/WEB-INF/tag/guan.tld"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
<link href="${pageContext.request.contextPath}/pages/admin/css/main.css"
	rel="stylesheet" type="text/css" />
<script src="${pageContext.request.contextPath}/scripts/jquery-1.7.1.js"
	language="javascript" type="text/javascript"></script>
</head>
<s:set name="entityName" value="%{actionName}" />
<body>
	<div class="mtitle">
		<h1>
			<s:property value="%{getText(#entityName+'.manager')}" />
		</h1>
		<!-- 
  <span> 跳转:
    <select class="fs_12" name="123">
      <option>所有频道</option>
    </select>
  </span>
   -->
	</div>
	<div class="tform">
		<s:url action="%{actionName}!form" namespace="%{nameSpace}"
			var="entityAddLink" />
		<!-- ${entity_goCreate} -->
		<!-- 操作按钮位置 -->
		<button type="button" class="btn1"
			onClick="location='${entityAddLink}'">
			<s:property value="%{getText('product.add')}" />
		</button>
		<!-- <button type='button' class="btn1" onClick="location='content_list.php?cid={dede:global.cid/}&mid=0';">全部数据</button>     
        <button type='button' class="btn1" onClick="location='content_list.php?cid={dede:global.cid/}&mid=<?php echo $cuserLogin->getUserID(); ?>';">我的数据</button>        
        <button type='button' class="btn1" onClick="location='catalog_main.php';">栏目管理</button>
        <button type='button' class="btn1" name='bb1' onClick="location='makehtml_list.php?cid={dede:global.cid/}';">更新列表</button>
        <button type='button' class="btn1" name='bb2' onClick="location='makehtml_archives.php?cid={dede:global.cid/}';">更新数据</button>
        <button type='button' class="btn1" name='bb1' onClick="location='recycling.php?cid={dede:global.cid/}';">文章回收站</button>
         -->
	</div>

	<!--  搜索表单  -->
	<s:form namespace="%{nameSpace}" method="post">
		<table width='100%' border='0' cellpadding='1' cellspacing='1'
			align="center" style="margin-top: 8px">
			<tr bgcolor='#f8f8f8'>
				<td align='center'>
					<table border='0' cellpadding='0' cellspacing='0'>
						<tr>
							<td width='90' align='center'>状态：</td>
							<td width='160'><select name='searchParam.isSoldOut'
								class="txt" style='width: 150'>
									<option value='false'>上架</option>
									<option value='true' <s:if test="soldOut">selected</s:if>>下架</option>
							</select> <!--<s:property value="soldOut"/>-->
							</td>
							<td width='70'>关键字：</td>
							<td width='160'><input name='searchParam.name' type='text'
								class="txt" style='width: 150px' value='' />
							</td>
							<!-- <td width='110'><select name='orderby' class="txt"
								style='width: 80px'>
									<option value='id'>排序...</option>
									<option value='pubdate'>发布时间</option>
									<option value='sortrank'>置顶权值</option>
									<option value='click'>点击量</option>
									<option value='postnum'>评论积分</option>
									<option value='lastpost'>最后评论</option>
							</select></td>
							 -->
							<td><s:submit key="common.text.search" cssClass="btn1"
									action="%{actionName}!list" namespace="%{nameSpace}"
									theme="simple" /></td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
	</s:form>

	<script>
		function selectAll(){
			var checkAll=document.getElementById("checkAll");
			var cks=document.getElementsByName("productIds");
			for(var i=0;i<cks.length;i++){
				cks[i].checked=checkAll.checked;
			}
		}
		
		function doSellOut(){
			var cks=document.getElementsByName("productIds");
			var hasSelected=false;
			for(var i=0;i<cks.length;i++){
				if(cks[i].checked){
					hasSelected=true;
				}
			}
			if(!hasSelected){
				alert("请选择要修改项");
			}else{
				if(confirm("确定将选择商品状态？")){
					document.getElementById("table-form").submit();
				}
			}
		}
	</script>


	<s:if test="soldOut">
		<s:set name="methodName" value="%{'onSell'}"></s:set>
	</s:if>
	<s:else>
		<s:set name="methodName" value="%{'sellOut'}"></s:set>
	</s:else>


	<s:form id="table-form" action="%{actionName}!%{methodName}"
		method="post" namespace="%{nameSpace}">
		<div style="text-align: right">
			<button type="button" class="btn1" onclick="doSellOut()">
				<s:property value="%{getText('product.sellOut')}" />
			</button>
		</div>
		<table class="tlist">
			<thead>
				<tr class="title">
					<th align="left"><s:property
							value="%{getText(#entityName+'.id')}" />
					</th>
					<th align="left"><input type="checkbox" id="checkAll"
						onclick="selectAll()" />
					</th>
					<th align="left"><s:property
							value="%{getText(#entityName+'.productFile')}" />
					</th>
					<th align="left"><s:property
							value="%{getText(#entityName+'.name')}" />
					</th>
					<th align="left"><s:property
							value="%{getText(#entityName+'.price')}" />
					</th>
					<th align="left"><s:property
							value="%{getText(#entityName+'.productCategory.name')}" />
					</th>
					<th align="left"><s:property
							value="%{getText('common.text.operate')}" />
					</th>
				</tr>
			</thead>
			<tbody>
				<s:iterator value="page.list" status="rowstatus">
					<tr>
						<td><s:property
								value="%{page.pageSize*page.currentPageNum+#rowstatus.index+1}" />
						</td>
						<td><input type="checkbox" name="productIds"
							value='<s:property value="id"/>' /> </ body>
						<td><img
							src="${pageContext.request.contextPath}/<s:property value="productFile.urlPath"/>"
							width="129px" height="44px" /></td>
						<td><s:property value="name" /></td>
						<td><s:property value="price" /></td>
						<td><s:property value="productCategory.name" /></td>
						<td><s:url namespace="%{nameSpace}"
								action="%{actionName}!form" var="entityEditLink">
								<s:param name="product.id" value="id"></s:param>
							</s:url> <a href="${entityEditLink}"> <s:property
									value="%{getText('common.text.edit')}" /> </a></td>
					</tr>
				</s:iterator>

			</tbody>
			<tfoot>
				<!-- 底部功能区 -->
				<!-- 
				
				<tr>
					<td colspan="9"><button type="button" class="btn1s"
							_click="allSelect">全选</button>
						<button type="button" class="btn1s" _click="unSelect">取消</button>
						<button type="button" class="btn1s"
							onClick="javascript:updateArc(0)">更新</button>
						<button type="button" class="btn1s"
							onClick="javascript:checkArc(0)">审核</button>
						<button type="button" class="btn1s" onClick="javascript:adArc(0)">推荐</button>
						<button type="button" class="btn1s"
							onClick="javascript:moveArc(0)">移动</button>
						<button type="button" class="btn1s" onClick="javascript:delArc(0)">删除</button>
					</td>
				</tr>
				 -->
			</tfoot>
		</table>


		<s:url action="%{actionName}!list" namespace="%{nameSpace}"
			var="pageUrlLink"></s:url>
		<g:pages url="%{pageUrlLink}" tpage="%{page.totalPageNum}"
			cpage="%{page.currentPageNum}" />
	</s:form>
</html>